﻿using System;
using log4net;
using log4net.Config;
using log4net.Appender;
using log4net.Layout;
using log4net.Core;

namespace _5._13._03.Log4Net
{
    class Log4NetBeginning
    {
        private static readonly ILog logger = LogManager.GetLogger(typeof(Log4NetBeginning));

        static void Main()
        {
            var fileAppender = new FileAppender();
            fileAppender.File = "log.txt";
            fileAppender.AppendToFile = true;
            fileAppender.Layout = new log4net.Layout.SimpleLayout();
            fileAppender.Threshold = Level.Warn; // from Warn to higher level including
            fileAppender.ActivateOptions();

            BasicConfigurator.Configure(fileAppender);

            logger.Info("Info message");
            logger.Error("Error message");
            logger.Warn("Warning message");
        }
    }
}